package datalookin.adapter2;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.whu.zj.MyApplication;
import com.whu.zj.R;

import java.util.List;

import main.dto.WaterPlant;

/**
 * Created by Administrator on 2016/6/27.
 */
public class ChooseAdapter extends BaseAdapter {

    List<WaterPlant> waterPlants;

    public void setWaterPlants(List<WaterPlant> waterPlants) {
        this.waterPlants = waterPlants;
    }

    @Override
    public int getCount() {
        if (waterPlants == null)
            return 0;
        return waterPlants.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        view = View.inflate(MyApplication.share(), R.layout.item_choose,null);
        TextView tv = (TextView) view.findViewById(R.id.id_text);

        WaterPlant waterPlant = waterPlants.get(i);
        tv.setText(waterPlant.getWaterPlantName());

        return view;
    }
}
